home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0017_Display MAKE-BREAK codes.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  64 lines

  1. PROGRAM ScanCode ;      { display MAKE and BREAK scan codes }
  2.  
  3. USES Crt, Dos, KeyIntr ;      { keyboard interrupt support }
  4.  
  5. { ----- this program will probably hang a debugger ----- }
  6.  
  7. Var
  8.    OldInt09 : Pointer ;
  9.    ExitSave : Pointer ;
  10.  
  11. {$F+} Procedure RestoreInt09 ;
  12. Begin
  13.    ExitProc := ExitSave ;
  14.    SetIntVec( $09, OldInt09 ) ;
  15. End ;
  16.  
  17. {$F+} Procedure NewInt09 ; Interrupt ;   { return scan code as key's value }
  18. Var
  19.    ScanCode : Byte ;
  20.    BufferFull : Boolean ;
  21.  
  22. Begin
  23.    EnableInterrupts ;
  24.    ScanCode := ReadScanCode ;
  25.    ResetKeyboard ;
  26.    BufferFull := Not StoreKey( ScanCode, ScanCode ) ;
  27.    EOI ;
  28.    If BufferFull then
  29.    Begin
  30.       Sound( 880 ) ;
  31.       Delay( 100 ) ;
  32.       Sound( 440 ) ;
  33.       Delay( 100 ) ;
  34.       NoSound ;
  35.    End ;
  36.                 { variation : move the EOI before the beep to after it }
  37.                 {      note the difference when the keyboard overflows }
  38. End ;
  39.  
  40. { see Turbo Pascal 5.0 reference p 450 for a list of scan codes }
  41. {                  6.0 programmers guide p 354                  }
  42.  
  43. Var
  44.    N  : Byte ;
  45.  
  46. BEGIN
  47.    ExitSave := ExitProc ;
  48.    ExitProc := @RestoreInt09 ;
  49.    GetIntVec( $09, OldInt09 ) ;
  50.    SetIntVec( $09, @NewInt09 ) ;
  51.  
  52.    WriteLn( '   Display "make" and "break" scan codes ' ) ;
  53.    WriteLn ;
  54.    WriteLn( '   Hit the <Esc> key to exit ' ) ;
  55.    Repeat
  56.       Delay( 400 ) ;               { make it easy to overrun keyboard }
  57.       N := Ord( ReadKey ) ;        { n is the scan code from NewInt09 }
  58.       If N < 128 then
  59.          WriteLn( 'Make  ', n )
  60.       Else
  61.          WriteLn( '    Break  ', n - 128 ) ;
  62.    Until n = 1 ;      { the make code for Esc }
  63. END.
  64.